# Adogs
# 时间: 2021/7/16 11:04
import pygame


class ActionImageCharater:
    def __init__(self, action_path: str, image_count: int, is_loop: bool):
        self.image_index = 0
        self.action_image = []
        self.image_count = image_count
        self.is_loop = is_loop
        for i in range(0, image_count):
            img_path = str.format(action_path % (i + 1))
            self.action_image.append(pygame.image.load(img_path))

    def get_image(self) -> pygame.image:
        current_img = self.action_image[self.image_index]
        if self.image_index + 1 >= self.image_count:
            if self.is_loop:
                self.image_index = 0
        else:
            self.image_index += 1
        return current_img

    def is_end(self) -> bool:
        if self.is_loop:
            return False
        else:
            if self.image_index >= self.image_count - 1:
                return True
            else:
                return False
